/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ie.tcd.cs.railtickets.server.domain;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.JoinColumn;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Wenbo Sun
 */
@Entity
@Table(name = "travel_path")
public class TravelPath implements Serializable {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "path_id")
    private long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "source_id")
    private RouteStation source;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "destination_id")
    private RouteStation destination;

    
    @Column(name = "price", precision = 10)
    private double price;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "path")
    private Set<PathTime> timeTables;

    public TravelPath() {
    }

    public TravelPath(long id) {
        this.id = id;
    }

    public TravelPath(RouteStation source, RouteStation destination, double price) {
        this.source = source;
        this.destination = destination;
        this.price = price;
    }

    public RouteStation getDestination() {
        return destination;
    }

    public void setDestination(RouteStation destination) {
        this.destination = destination;
    }

    public RouteStation getSource() {
        return source;
    }

    public void setSource(RouteStation source) {
        this.source = source;
    }


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public Set<PathTime> getTimeTables() {
        return timeTables;
    }

    public void setTimeTables(Set<PathTime> timeTables) {
        this.timeTables = timeTables;
    }
}
